package com.ruoyi.projects.service.impl;

import java.util.Collections;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.projects.mapper.SlMemberCardMapper;
import com.ruoyi.projects.domain.SlMemberCard;
import com.ruoyi.projects.service.ISlMemberCardService;

/**
 * 用户会员卡Service业务层处理
 * 
 * @author yangz
 * @date 2024-12-01
 */
@Service
public class SlMemberCardServiceImpl implements ISlMemberCardService 
{
    @Autowired
    private SlMemberCardMapper slMemberCardMapper;

    /**
     * 查询用户会员卡
     * 
     * @param cardId 用户会员卡主键
     * @return 用户会员卡
     */
    @Override
    public SlMemberCard selectSlMemberCardByCardId(Long cardId)
    {
        return slMemberCardMapper.selectSlMemberCardByCardId(cardId);
    }

    /**
     * 查询用户会员卡列表
     * 
     * @param slMemberCard 用户会员卡
     * @return 用户会员卡
     */
    @Override
    public List<SlMemberCard> selectSlMemberCardList(SlMemberCard slMemberCard)
    {
        return slMemberCardMapper.selectSlMemberCardList(slMemberCard);
    }

    /**
     * 新增用户会员卡
     * 
     * @param slMemberCard 用户会员卡
     * @return 结果
     */
    @Override
    public int insertSlMemberCard(SlMemberCard slMemberCard)
    {
        slMemberCard.setCreateTime(DateUtils.getNowDate());
        slMemberCard.setCardNo(DateUtils.generateOrderNo());
        return slMemberCardMapper.insertSlMemberCard(slMemberCard);
    }

    /**
     * 修改用户会员卡
     * 
     * @param slMemberCard 用户会员卡
     * @return 结果
     */
    @Override
    public int updateSlMemberCard(SlMemberCard slMemberCard)
    {
        slMemberCard.setUpdateTime(DateUtils.getNowDate());
        return slMemberCardMapper.updateSlMemberCard(slMemberCard);
    }

    /**
     * 批量删除用户会员卡
     * 
     * @param cardIds 需要删除的用户会员卡主键
     * @return 结果
     */
    @Override
    public int deleteSlMemberCardByCardIds(Long[] cardIds)
    {
        return slMemberCardMapper.deleteSlMemberCardByCardIds(cardIds);
    }

    /**
     * 删除用户会员卡信息
     * 
     * @param cardId 用户会员卡主键
     * @return 结果
     */
    @Override
    public int deleteSlMemberCardByCardId(Long cardId)
    {
        return slMemberCardMapper.deleteSlMemberCardByCardId(cardId);
    }

    /**
     * 查询我的会员卡列表
     * @return
     */
    @Override
    public List<SlMemberCard> listMyCards(Long userId) {
        SlMemberCard slMemberCard = new SlMemberCard();
        slMemberCard.setCustomId(userId);
        return slMemberCardMapper.selectSlMemberCardList(slMemberCard);
    }
}
